#include "Logger.h"
#include "Timestamp.h"

#include <iostream>

Logger &Logger::get_instance()
{
    static Logger logger;
    return logger;
}

// 输出[logger_level] time : msg
void Logger::log(const std::string &msg)
{
    std::cout << "[";
    switch (logger_lever_)
    {
    case INFO:
        std::cout << "INFO";
        break;
    case FATAL:
        std::cout << "FATAL";
        break;
    case ERROR:
        std::cout << "ERROR";
        break;
    case DEBUG:
        std::cout << "DEBUG";
        break;
    default:
        break;
    }

    std::cout << "] " << Timestamp::now().tostring() + " " << msg << std::endl;
}

void Logger::set_logger_level(Logger_level log_level)
{
    this->logger_lever_ = log_level;
}
